package com.naiterui.ehp.bs.b2c.order.service.impl.logistics;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.springframework.core.ParameterizedTypeReference;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.naiterui.ehp.bs.b2c.order.bo.LogisticsInfoBO;
import com.naiterui.ehp.bs.b2c.order.service.ILogisticsTraceService;
import com.naiterui.ehp.bs.b2c.order.vo.logistics.BaseRequest;
import com.naiterui.ehp.bs.b2c.order.vo.logistics.BaseResponse;

public abstract class AbstractLogisticsTraceService<T extends BaseRequest> extends DefaultLogisticsTraceServiceImpl implements ILogisticsTraceService {

    protected abstract <E extends BaseResponse> E execute(T t, ParameterizedTypeReference<E> responseTypeReference) throws IOException;

    /**
     * 根据快递单号获取快递信息
     *
     * @param deliveryIds 快递单号
     *
     * @return 物流信息
     */
    public Map<String, LogisticsInfoBO> getTrace(List<String> deliveryIds) {
        return Maps.newHashMap();
    }

    /**
     * 根据快递单号获取快递信息
     *
     * @param deliveryId 快递单号
     *
     * @return 物流信息
     */
    public LogisticsInfoBO getTrace(String deliveryId) {
        Map<String, LogisticsInfoBO> stringListMap = this.getTrace(Lists.newArrayList(deliveryId));
        return stringListMap.get(deliveryId);
    }

}
